import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from "@dfeidao/atom-web/render/render";
import p001 from './p001';

export default async function a001(fd: IFeidaoAiBrowserComponent) {
	// todo
	const n = fd.data.node.querySelector<HTMLInputElement>('[data-id="plan_name"]');
	const v = n.value;

	const s = fd.data.node.querySelector<HTMLInputElement>('[data-id="start_time"]').value;
	const e = fd.data.node.querySelector<HTMLInputElement>('[data-id="end_time"]').value;
	console.log(s, e, v);

	if (s && e) {
		if (s > e) {
			alert("开始时间不能大于结束时间");
			return;
		}
	}
	const res = await nodejs<{ res: Array<{}>; c: number; }>('plan-cb/zj-000001/s001', {
		filter: {
			pn: 1,
			start_time: s,
			end_time: e,
			plan_name: v
		}
	});
	console.log('s', res);
	render(fd, res, p001, 'p001', 'inner');
}
